import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import dayjs from "dayjs";

export const columns: BasicColumn[] = [
    {
    title: '云平台用户标识',
    dataIndex: 'uid',
    width: '300px',
   },
   {
    title: '云平台类型',
    dataIndex: 'type'
   },
   {
    title: '有效期开始',
    dataIndex: 'beginTime'
   },
   {
    title: '有效期结束',
    dataIndex: 'endTime'
   },
];

export const searchFormSchema: FormSchema[] = [
 {
    label: '云平台用户标识',
    field: 'uid',
    component: 'Input'
  },
 {
    label: '云平台类型',
    field: 'type',
    component: 'Input'
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  {label: '', field: 'id', component: 'Input', show: false},
  {
    label: '云平台用户标识',
    field: 'uid',
    component: 'Input',
    required: true,
  },
  {
    label: '云平台类型',
    field: 'type',
    component: 'Input',
    required: true,
  },
  {
    label: '有效期开始',
    field: 'beginTime',
    component: 'DatePicker',
    componentProps: {
      //日期格式化，页面上显示的值
      format: 'YYYY-MM-DD HH:mm:ss',
      //返回值格式化（绑定值的格式）
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      //是否显示今天按钮
      showToday: true,
      //不可选择日期
      disabledDate: (currentDate) => {
        let date = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss');
        let nowDate = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
        //当天不可选择
        if (date == nowDate) {
          return true;
        }
        return false;
      },
    },
  },
  {
    label: '有效期结束',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      //日期格式化，页面上显示的值
      format: 'YYYY-MM-DD HH:mm:ss',
      //返回值格式化（绑定值的格式）
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      //是否显示今天按钮
      showToday: true,
      //不可选择日期
      disabledDate: (currentDate) => {
        let date = dayjs(currentDate).format('YYYY-MM-DD HH:mm:ss');
        let nowDate = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
        //当天不可选择
        if (date == nowDate) {
          return true;
        }
        return false;
      },
    },
  },
];
